package com.hjh.netty.elect.demo4;

import com.hjh.netty.elect.util.NumberDataConvertUtils;
import org.springframework.stereotype.Service;

/**
 * 需量数据解析(子类=0x04，版本=0)
 * @author pyz
 *
 */
@Service("analysisDemandUpLoadDataService")
public class AnalysisDemandUpLoadDataService implements AnalysisUpLoadDataService{
	
	@Override
	public SubType4TypeVer0 analysisUpLoadData(String upLoadData) {
		int index = 0;
		SubType4TypeVer0 result = new SubType4TypeVer0();
		//A 相电流实时需量
		String I1DMD = upLoadData.substring(index, index + 8);
		result.setI1DMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(I1DMD));
		index += 8;
		//B 相电流实时需量
		String I2DMD = upLoadData.substring(index, index + 8);
		result.setI2DMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(I2DMD));
		index += 8;
		//C 相电流实时需量
		String I3DMD = upLoadData.substring(index, index + 8);
		result.setI3DMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(I3DMD));
		index += 8;
		//总有功功率实时需量
		String PImpDMD = upLoadData.substring(index, index + 8);
		result.setPImpDMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(PImpDMD));
		index += 8;
		//总无功功率实时需量
		String QImpDMD = upLoadData.substring(index, index + 8);
		result.setQImpDMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(QImpDMD));
		index += 8;
		//总视在功率实时需量
		String SDMD = upLoadData.substring(index, index + 8);
		result.setSDMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(SDMD));
		index += 8;
		//A 相电流预测需量
		String I1PredDMD = upLoadData.substring(index, index + 8);
		result.setI1PredDMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(I1PredDMD));
		index += 8;
		//B 相电流预测需量
		String I2PredDMD = upLoadData.substring(index, index + 8);
		result.setI2PredDMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(I2PredDMD));
		index += 8;
		//C 相电流预测需量
		String I3PredDMD = upLoadData.substring(index, index + 8);
		result.setI3PredDMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(I3PredDMD));
		index += 8;
		//总有功功率预测需量
		String PImpPredDMD = upLoadData.substring(index, index + 8);
		result.setPImpPredDMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(PImpPredDMD));
		index += 8;
		//总无功功率预测需量
		String QImpPredDMD = upLoadData.substring(index, index + 8);
		result.setQImpPredDMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(QImpPredDMD));
		index += 8;
		//总视在功率预测需量
		String SPredDMD = upLoadData.substring(index, index + 8);
		result.setSPredDMD(NumberDataConvertUtils.hexFloatString2decimalFloatString(SPredDMD));
		index += 8;
		return result;
	}

}
